home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 12: Textmags & Docs / nf_archive_12.iso / MAGS / SOURCES / ATARI_SRC.ZIP / atari source / FALCON / ACC / OUTLINE.ACC / INACTIVE.C < prev    next >
Encoding:
C/C++ Source or Header  |  2001-02-10  |  10.0 KB  |  433 lines

  1. /* ===================================================================
  2.  * FILE: INACTIVE.C
  3.  * ===================================================================
  4.  * DATE: December  9, 1992  Combine BitMap and Outline Fonts
  5.  *     December 15, 1992  Remove Bitmap fonts and devices
  6.  * 
  7.  * DESCRIPTION: Fonts ACC
  8.  *
  9.  * This file handles the available fonts dialog box.
  10.  *
  11.  * COMPILER: TURBO C Version 2.0
  12.  */
  13.  
  14.  
  15. /* INCLUDE FILES
  16.  * ===================================================================
  17.  */
  18. #include <sys\gemskel.h>
  19. #include <tos.h>
  20. #include <linea.h>
  21. #include <string.h>
  22. #include <stdio.h>
  23.  
  24. #include "country.h"
  25. #include "fonthead.h"
  26. #include "fonts.h"
  27. #include "mainstuf.h"
  28. #include "text.h"
  29. #include "fsmio.h"
  30. #include "mover.h"
  31. #include "front.h"
  32. #include "points.h"
  33. #include "options.h"
  34.  
  35.  
  36. /* STRUCTURES
  37.  * ===================================================================
  38.  */
  39.  
  40.  
  41. /* EXTERN
  42.  * ===================================================================
  43.  */
  44. extern int AES_Version;
  45.  
  46.  
  47.  
  48. /* PROTOTYPES
  49.  * ===================================================================
  50.  */
  51. void    DoAvailable( void );
  52. int    HandleAvailable( int button, WORD *msg );
  53. void    MoveToInstalled( int flag );
  54. int    CheckForFontsInDevices( void );
  55. void    AddToScreenDevices( FON_PTR curptr, int flag );
  56. void    DoSelectAll( void );
  57. void    SelectAllUnusedFonts( void );
  58. void    CheckSelectAll( int draw );
  59.  
  60.  
  61.  
  62. /* DEFINES
  63.  * ===================================================================
  64.  */
  65. #define MENU_WIDTH  32
  66. #define UNDO    0x6100
  67. #define ACTIVE        0
  68. #define INACTIVE    1
  69. #define FRONT_HEIGHT  14
  70. #define INACTIVE_HEIGHT 14
  71.  
  72.  
  73.  
  74. /* GLOBALS
  75.  * ===================================================================
  76.  */
  77.  
  78.  
  79. /* FUNCTIONS
  80.  * ===================================================================
  81.  */
  82.  
  83.  
  84. /* DoAvailable()
  85.  * ===================================================================
  86.  */
  87. void
  88. DoAvailable( void )
  89. {
  90.     PrevTree = ad_front;
  91.     Reset_Tree( ad_inactive );
  92.  
  93.  
  94.     NoExit( IINSTALL );
  95.     Disable( IINSTALL );
  96.     
  97.     NoExit( ICONFIG );
  98.     Disable( ICONFIG );
  99.  
  100.  
  101.     /* Read in the UnUsed fonts, if necessary */
  102.     
  103.     if( !Fonts_Loaded )
  104.     {
  105.       MF_Save();
  106.       Scan_Message( ad_scan, TRUE );    
  107.  
  108.       read_fonts( TRUE, FALSE );
  109.  
  110.       Scan_Message( ad_scan, FALSE );
  111.       MF_Restore();
  112.     }  
  113.  
  114.     CheckSelectAll( FALSE );
  115.     
  116.     mover_setup( available_list, available_count,
  117.          IBASE, ISLIDER, IUP, IDOWN,
  118.          ILINE0, ILINE13, ILINE, 0, INACTIVE_HEIGHT );
  119.     HideObj( ILINE );         
  120.     Objc_draw( tree, ROOT, MAX_DEPTH, NULL ); 
  121.     ShowObj( ILINE );
  122.     RedrawBase( tree, ILINE );
  123. }
  124.  
  125.  
  126.  
  127. /* HandleAvailable()
  128.  * ===================================================================
  129.  */
  130. int
  131. HandleAvailable( int button, WORD *msg )
  132. {
  133.    int     quit;
  134.    int     dclick;
  135.    FON_PTR curptr;
  136.  
  137.    
  138.    dclick = FALSE;  
  139.    quit   = FALSE;
  140.       
  141.    /* Handle Double-clicking of the objects */   
  142.    if( ( button != -1 ) && ( button & 0x8000 ) )
  143.    {
  144.       button &= 0x7FFF;
  145.       dclick = TRUE;
  146.    }   
  147.    
  148.    switch( button )
  149.    {
  150.      case IEXIT:    Deselect( IEXIT );
  151.  
  152.             ClearFnodes( installed_list );
  153.             ClearFnodes( available_list );
  154.  
  155.             Reset_Tree( ad_front );     
  156.  
  157.             CheckInstallAll( FALSE );
  158.                         
  159.                     mover_setup( installed_list, installed_count,
  160.                          FBASE, FSLIDER, FUP, FDOWN,
  161.                    LINE0, LINE13, LINEBASE, 0, FRONT_HEIGHT );
  162.             HideObj( LINEBASE );               
  163.             Objc_draw( tree, ROOT, MAX_DEPTH, NULL ); 
  164.             ShowObj( LINEBASE );
  165.             RedrawBase( tree, LINEBASE );
  166.                  break;
  167.  
  168.      case ILINE0:
  169.      case ILINE1:
  170.      case ILINE2:
  171.      case ILINE3:
  172.      case ILINE4:
  173.      case ILINE5:
  174.      case ILINE6:
  175.      case ILINE7:
  176.      case ILINE8:
  177.      case ILINE9:
  178.      case ILINE10:
  179.      case ILINE11:
  180.      case ILINE12:
  181.      case ILINE13:  if( dclick )
  182.                  {
  183.                   curptr = Active_Slit[ button - First_Obj ];
  184.                   if( !curptr )
  185.                         return( quit );          
  186.               DoPoints( tree, button );
  187.                  }
  188.                  else
  189.                    mover_button( button, dclick );
  190.                  break;
  191.  
  192.  
  193.      case IUP:
  194.      case IDOWN:
  195.      case IBASE:
  196.      case ISLIDER:  mover_button( button, dclick );
  197.             break;
  198.  
  199.  
  200.      case IINSTALL: if( IsChanged( available_list ) )
  201.                  {  
  202.                 /* ASK if we want it install these fonts first.*/
  203.                if( form_alert( 1, alert58 ) == 2 )
  204.                {
  205.                    XDeselect( tree, IINSTALL );
  206.                    return( quit );
  207.                }       
  208.                MoveToInstalled( FALSE );
  209.                  }   
  210.                 XDeselect( tree, IINSTALL );
  211.                  break;
  212.  
  213.      case ICONFIG:  Deselect( ICONFIG );
  214.             if( DoPoints( ad_inactive, 0 ))
  215.                XDeselect( tree, ICONFIG );
  216.             break;
  217.  
  218.      case ISELECT:  DoSelectAll();
  219.             XDeselect( tree, ISELECT );
  220.                  break;
  221.                  
  222.      default:     if( button == -1 )
  223.               {
  224.                 switch( msg[0] )
  225.                 {
  226.                   case WM_REDRAW: 
  227.                                break;
  228.                                    
  229.                   case AC_CLOSE:  quit = TRUE;
  230.                                break;
  231.                                        
  232.                   case WM_CLOSED: quit = TRUE;
  233.                                CloseWindow();
  234.                      break;
  235.  
  236.              case CT_KEY:    if( msg[3] == UNDO )
  237.                         Undo_Fnodes( available_list, ( FON_PTR )NULL );
  238.                           break;
  239.                   default:
  240.                           break;
  241.                 }
  242.               }
  243.               else
  244.                Undo_Fnodes( available_list, ( FON_PTR )NULL );
  245.               break;
  246.    }
  247.    return( quit );
  248.  
  249. }
  250.  
  251.  
  252. /* MoveToInstalled()
  253.  * ====================================================================
  254.  * Move any Available fonts to the Installed List.
  255.  * type -> 0 -> USE Available list CALLS
  256.  *      -> 1 -> Skip available list calls
  257.  */
  258. void
  259. MoveToInstalled( int flag )
  260. {
  261.     FON_PTR curptr;
  262.     FON_PTR xcurptr;
  263.     int     index;
  264.  
  265.     curptr = available_list;
  266.  
  267.     /* Try to maintain the top node displayed to remain that way if
  268.      * at all possible.
  269.      */
  270.     xcurptr = Active_Slit[ 0 ];
  271.     if( curptr && xcurptr )
  272.         index = Get_Findex( curptr, xcurptr );
  273.  
  274.     /* Go through the list looking for selected nodes ( AFLAG == TRUE )
  275.      * and set their SEL() to FALSE.
  276.      * Where SEL == TRUE means installed. and SEL == FALSE means 
  277.      * available.
  278.      * Set MakeWidth Tables flag if moving Outline Fonts TO INSTALLED!
  279.      */
  280.     while( curptr )
  281.     {
  282.        if( AFLAG( curptr ) )
  283.        {
  284.            if( FTYPE( curptr ) == SPD_FONT )
  285.              MakeWidthFlag = TRUE;
  286.            SEL( curptr ) = TRUE;
  287.        }    
  288.        curptr = FNEXT( curptr );
  289.     }
  290.  
  291.  
  292.     /* Now, fix up the linked list for both the
  293.      * available and installed fonts.
  294.      */
  295.     free_arena_links();
  296.     installed_count = build_list( &installed_list, &installed_last, ACTIVE );
  297.     available_count = build_list( &available_list, &available_last, INACTIVE );
  298.  
  299.     /* Prompt to save SYS files */
  300.     SetChangeFlag();
  301.  
  302.     if( !flag )
  303.     {
  304.        mover_setup( available_list, available_count,
  305.             IBASE, ISLIDER, IUP, IDOWN,
  306.             ILINE0, ILINE13, ILINE, index, INACTIVE_HEIGHT );
  307.  
  308.        RedrawObject( tree, IBASE );
  309.        Objc_draw( tree, ILINE, MAX_DEPTH, NULL );
  310.     
  311.        if( !IsDisabled( IINSTALL ) )
  312.           ChangeButton( ad_inactive, IINSTALL, FALSE );
  313.     
  314.        if( !IsDisabled( ICONFIG ) )
  315.           ChangeButton( ad_inactive, ICONFIG, FALSE );
  316.           
  317.        CheckSelectAll( TRUE );
  318.     }      
  319. }
  320.  
  321.  
  322.  
  323.  
  324. /* DoSelectAll()
  325.  * ====================================================================
  326.  */
  327. void
  328. DoSelectAll( void )
  329. {
  330.     int  index;
  331.     int  ocount;
  332.     int  unselected;
  333.     
  334.     /* Count Number of Selected Fonts */
  335.     ocount = CountSelectedFonts( available_list, SPD_FONT );
  336.     unselected = available_count - ocount;
  337.     
  338.     if( !unselected )
  339.     {
  340.         form_alert( 1, nosel );
  341.         ChangeButton( ad_inactive, ISELECT, FALSE );
  342.         return;
  343.     }
  344.     
  345.     if( form_alert( 1, selall ) == 1 )
  346.     {
  347.        SelectAllUnusedFonts();
  348.        
  349.        index = Get_Findex( available_list, Active_Slit[0] );
  350.  
  351.        mover_setup( available_list, available_count,
  352.             IBASE, ISLIDER, IUP, IDOWN,
  353.             ILINE0, ILINE13, ILINE, index, INACTIVE_HEIGHT );
  354.  
  355.        RedrawObject( tree, IBASE );
  356.        Objc_draw( tree, ILINE, MAX_DEPTH, NULL );
  357.  
  358.        if( IsDisabled( IINSTALL ) )
  359.           ChangeButton( ad_inactive, IINSTALL, TRUE );
  360.     
  361.        if( IsDisabled( ICONFIG ) )
  362.           ChangeButton( ad_inactive, ICONFIG, TRUE );
  363.     }   
  364.     CheckSelectAll( TRUE );
  365. }
  366.  
  367.  
  368.  
  369.  
  370. /* SelectAllUnusedFonts()
  371.  * ====================================================================
  372.  */
  373. void
  374. SelectAllUnusedFonts( void )
  375. {
  376.    FON_PTR curptr;
  377.    
  378.    curptr = available_list;
  379.    while( curptr )
  380.    {
  381.        if( !SEL( curptr ) )
  382.           AFLAG( curptr ) = TRUE;
  383.        curptr = FNEXT( curptr );          
  384.    }  
  385. }
  386.  
  387.  
  388.  
  389. /* CheckSelectAll() 
  390.  * ====================================================================
  391.  */
  392. void
  393. CheckSelectAll( int draw )
  394. {
  395.     int  ocount;
  396.     int  unselected;
  397.     
  398.     /* Count Number of Selected Fonts */
  399.     ocount = CountSelectedFonts( available_list, SPD_FONT );
  400.     unselected = available_count - ocount;
  401.     
  402.     /* If we have some unselected available fonts, then enable button */
  403.     if( unselected )
  404.     {
  405.       if( IsDisabled( ISELECT ) )
  406.       {
  407.          if( draw )
  408.             ChangeButton( ad_inactive, ISELECT, TRUE );
  409.          else
  410.          {
  411.             Enable( ISELECT );
  412.             MakeExit( ISELECT );
  413.          }
  414.       }   
  415.          
  416.     }
  417.     else
  418.     {
  419.       /* No more fonts to select, shut it off */
  420.       if( !IsDisabled( ISELECT ) )
  421.       {
  422.          if( draw )
  423.             ChangeButton( ad_inactive, ISELECT, FALSE );
  424.          else
  425.          {
  426.             Disable( ISELECT );
  427.             NoExit( ISELECT );
  428.          }
  429.       }   
  430.     
  431.     }
  432. }
  433.